package com.power.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.power.model.pojo.Menu;
import com.power.service.MenuService;

@RestController
@RequestMapping("/menu")
public class MenuController {
	@Autowired 
	MenuService ms;
	List<Menu> list;
	@RequestMapping("/all")
	public List<Menu> selectRoleMenu(@Param("rid")String rid){
		
		List<Integer> lists=new ArrayList<Integer>();
		String arr[]=rid.split(",");
		for(int i=0;i<arr.length;i++) {
			
			lists.add(Integer.parseInt(arr[i]));
		}
		System.out.println(lists+"----------------------------------");
		 list=ms.selectRoleMenu(lists);
		return list;
	}
	/**
	 * 查询所有菜单信息  comtion 页面的菜单的树形控件
	 * @return
	 */
	@RequestMapping("/getMenu")
	public List<Menu> selectAll(){
		list=ms.selectAll();
		return list;
	}
	@RequestMapping("/getRid")
	public List<Menu> selectByRid(Integer rid){
		return ms.selectByRid(rid);
	}
}
